//package aio;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.io.OutputStream;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//import java.util.concurrent.Future;
//import javax.servlet.http.HttpServletResponse;
//import java.io.*;
//public class eq {
//    public static void main(String[] args) {
//        public void www(HttpServletResponse response) throws IOException {
//            ExecutorService service = Executors.newCachedThreadPool();
//            File file = new File("uuu");
//            FileInputStream inputStream = new FileInputStream(file);
//            long avgPart = file.length() / 4;
//            OutputStream outputStream = response.getOutputStream();
//            List<Future<?>> futures = new ArrayList<>();
//            for (int i = 0; i < 4; i++) {
//                long startPos = avgPart + 1;
//                futures.add(service.submit(()->{
//                    try {
//                        inputStream.skip(startPos);
//                        byte[] bytes = new byte[1024];
//                        int readCount = 0;
//                        int resultCount = 0;
//                        resultCount += 1024;
//                        boolean ss = false;
//                        if (readCount > avgPart) {
//                            bytes = new byte[resultCount - 1024];
//                            ss = true;
//                        }
//                        while ((readCount = inputStream.read(bytes)) != -1) {
//                            outputStream.write(bytes,0,readCount);
//                            if (ss) {
//                                return;
//                            }
//                        }
//                    } catch (IOException e) {
//                        throw new RuntimeException(e);
//                    }
//
//                }));
//
//            }
//            try {
//                inputStream.close();
//                outputStream.close();
//            } catch (IOException e) {
//                throw new RuntimeException(e);
//            }
//
//        }
//    }
//}
